<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<style>
<!--
.h10{
	height: 10px;
}
-->
</style>
	<div class="m-b-md">
		<div class="h10"></div>
		<form class="form-inline" role="form" id="searchForm" name="searchForm">
			<div class="form-group">
				<label class="control-label">
				<span>机构名称:</span></label>
				<input class="form-control" id="orgName" qt="like" name="orgInfoFormMap.orgName">
			</div>
			<div class="form-group">
				<label class="control-label">
				<span>联系人:</span></label>
				<input class="form-control" id="contact" qt="like" name="orgInfoFormMap.contact">
			</div>
			<div class="form-group">
				<label class="control-label">
				<span>联系电话:</span></label>
				<input class="form-control" id="phone" qt="like" name="orgInfoFormMap.phone">
			</div>
			<a href="javascript:void(0)" class="btn btn-default" id="search">查询</a>
			<a href="javascript:grid.exportData('/integral/exportOrg.shtml')" class="btn btn-info" id="search">导出excel</a>
		</form>
	</div>
	<header class="panel-heading">
	<div class="doc-buttons">
		<c:forEach items="${res}" var="key">
			${key.description}
		</c:forEach>
	</div>
	</header>
	<div class="table-responsive">
		<div id="paging" class="pagclass"></div>
	</div>
	
<script type="text/javascript">

var dict = [];
<c:forEach items="${dict }" var="record">
dict.push({'value':'${record.value}','label':'${record.label}'});
</c:forEach>

var pageii = null;
var grid = null;
$(function() {
	grid = lyGrid({
		pagId : 'paging',
		l_column : [ {
			colkey : "id",
			name : "操作",
			width : "55px",
			renderData : function(rowindex,data, rowdata, column) {
				return "<img class='imgbtn' title='查看' src='" + rootPath + "/images/view.png' onclick=\"viewFun('"+data+"')\"/>";
			}
		}, {
			colkey : "orgName",
			name : "机构名称"
		}, {
			colkey : "owner",
			name : "法人"
		}, {
			colkey : "orgCode",
			name : "组织机构代码"
		}, {
			colkey : "contact",
			name : "联系人"
		}, {
			colkey : "phone",
			name : "联系电话"
		},  {
			colkey : "integral",
			name : "机构积分"
		},{
			colkey : "createTime",
			name : "申请时间",
			renderData : function(rowindex,data, rowdata, column) {
				return new Date(data).format("yyyy-MM-dd hh:mm:ss");
			}
		}],
		jsonUrl : rootPath + '/integral/findOrgIntegralByPage.shtml',
		checkbox : true
	});
	$("#search").click("click", function() {// 绑定查询按扭
		var searchParams = $("#searchForm").serializeJson();// 初始化传参数
		$("input[qt=like]").each(function() {
			if ($(this).val().trim() != "") {
				searchParams[$(this).attr("name")] = "%" + $(this).val().trim() + "%";
			}
		});
		grid.setOptions({
			data : searchParams
		});
	});
	$("#passFun").click("click", function() {
		passFun();
	});
	$("#rejectFun").click("click", function() {
		rejectFun();
	});
	$("#viewFun").click("click", function() {
		viewFun();
	});
});
function passFun(cbox) {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择机构！！");
		return;
	}
	layer.confirm('确认审核通过？', function(index) {
		var url = rootPath + '/org/pass.shtml';
		var s = CommnUtil.ajax(url, { ids : cbox.join(",") }, "json");
		if (s == "success") {
			layer.msg('操作成功');
			grid.loadData();
		} else {
			layer.msg('操作失败');
		}
	});
}

function rejectFun(cbox) {
	var cbox = grid.getSelectedCheckbox();
	if (cbox == "") {
		layer.msg("请选择机构！！");
		return;
	}
	layer.confirm('确认审核拒绝？', function(index) {
		var url = rootPath + '/org/reject.shtml';
		var s = CommnUtil.ajax(url, { ids : cbox.join(",") }, "json");
		if (s == "success") {
			layer.msg('操作成功');
			grid.loadData();
		} else {
			layer.msg('操作失败');
		}
	});
}

function viewFun(cbox) {
	pageii = layer.open({
		title : "查看",
		type : 2,
		area : [ "900px", "530px" ],
		content : rootPath + '/integral/viewDetail.shtml?id=' + cbox+'&type='+1
	});
}
</script>